package BehavioralMode.memento.blackBox.gameFile;

/**
 * 发起人角色
 * */
public class Originator {
    // 内部私有备忘录
    private class GameMemnto implements Memento {
        private int vie;  // 生命力
        private int act;  // 攻击力
        private int def;  // 防御力

        public GameMemnto(int vie, int act, int def) {
            this.vie = vie;
            this.act = act;
            this.def = def;
        }

        public int getVie() {
            return this.vie;
        }

        public int getAct() {
            return this.act;
        }

        public int getDef() {
            return this.def;
        }
    }

    private int vie;  // 生命力
    private int act;  // 攻击力
    private int def;  // 防御力

    public void initStatus(){
        this.vie = 100;
        this.act = 100;
        this.def = 100;
    }

    // 显示状态
    public void showStatus() {
        System.out.print("生命值："+ vie);
        System.out.print("攻击力："+ act);
        System.out.println("防御力："+ def);
    }

    // 攻击boss
    public void attackBoss(){
        vie-=20;
        act-=20;
        def-=20;
        if(this.vie < 0)vie = 20;
        if(this.act < 0)act = 20;
        if(this.def < 0)def = 20;

    }

    // 保存状态
    public GameMemnto createMemnto(){
        return new GameMemnto(vie,act,def);
    }

    // 恢复存档
    public void restore(Memento memento){
        GameMemnto gameMemnto = (GameMemnto) memento;

        this.vie = gameMemnto.getVie();
        this.act = gameMemnto.getVie();
        this.def = gameMemnto.getDef();
    }


}
